import {
    deleteRequest,
    getRequest, postRequest
} from '@/lib/request';

export const homeApi = {
    getBanner: (type) => {
        return getRequest('/banners')
    },
    //今日推荐课程
    getTodayRecommended: () => {
        return getRequest('/course/today-recommended')
    },
    //今日推荐课程
    getTodayRecommendedList: (data) => {
        return getRequest(`/course/today-recommended-list?page=${data.page}`)
    },
    //热门课程
    getHotCourse: () => {
        return getRequest('/course/hot-courses')
    },
    // 讲师推荐课程
    getTeacherRecommended: () => {
        return getRequest('/course/instructor-recommended')
    },
    // 获取最新好课
    getLatestCourses: () => {
        return getRequest('/course/latest-courses')
    },
    // 获取最新好课
    getLatestCourses: () => {
        return getRequest('/course/latest-courses')
    },
    // 课程搜索
    getSearch: (data) => {
        return getRequest(`/course/search?keyword=${data.keyword}&page=${data.page}&sort_order=${data.sort_order}&sort_by=${data.sort_by}&category_id=${data.category_id}`)
    },
    // 课程分类导航
    getCourseCategories: () => {
        return getRequest('/course/categories')
    },
    // 通知
    getNotificationsLatest: () => {
        return getRequest('/notifications/latest')
    },
    // 通知详情
    getNotificationsId: (id) => {
        console.log(id)
        return getRequest(  `/notifications/${id}`)
    },
    // 通知列表
    getNotifications: (data) => {
        return getRequest(`/notifications?page=${data.page}`)
    },
    // 通知评论列表
    getNotificationsComments: (data) => {
        return getRequest(`/notifications/${data.id}/comments?page=${data.page}`)
    },
    // 回复通知评论
    notificationsComments: (param) => {
        return postRequest('/notifications/comments', param);
    },
    // 消息获取更多二级评论
    getCommentsReplies: (data) => {
        return getRequest(`/notifications/comments/${data.id}/replies?page=${data.page}`)
    },
    // 消息删除评论
    delComments: (data) => {
        return deleteRequest(`/notifications/comments/${data.id}`)
    },
    // 课程详细
    getCourse: (data) => {
        return getRequest(`/course/${data.id}`)
    },
    // 获取课程评论列表
    getCourseComments: (data) => {
        return getRequest(`/course/${data.id}/comments?page=${data.page}`)
    },
    // 回复课程通知评论
    courseComments: (param) => {
        return postRequest('/course/comment/add', param);
    },
    // 课程删除评论
    delCourse: (data) => {
        return deleteRequest(`/course/comment/${data.id}`)
    },
    // 课程获取更多二级评论
    getCourseCommentsReplies: (data) => {
        return getRequest(`/comments/${data.id}/replies?page=${data.page}`)
    },
    // 视频观看接口
    getWatch: (data) => {
        return getRequest(`/${data.id}/watch?duration=0`)
    },
    // 收藏课程
    addFavorite: (data) => {
        return postRequest(`/course/favorite`, data)
    },
    // 取消收藏
    removeFavorite: (data) => {
        return postRequest(`/course/unfavorite`, data)
    },
    // 学习轨迹
    getLearningTrack: () => {
        return getRequest(`/learning-track`)
    },
    // 课程分类
    getAllCategories: () => {
        return getRequest(`/course/all-categories`)
    },
}
